package cn.edu.scau.dropship.mapper;

import cn.edu.scau.dropship.entity.Company;
import cn.edu.scau.dropship.entity.CompanyExample;
import java.util.List;
import org.apache.ibatis.annotations.Arg;
import org.apache.ibatis.annotations.ConstructorArgs;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface CompanyMapper {
    @SelectProvider(type=CompanySqlProvider.class, method="countByExample")
    long countByExample(CompanyExample example);

    @DeleteProvider(type=CompanySqlProvider.class, method="deleteByExample")
    int deleteByExample(CompanyExample example);

    @Delete({
        "delete from company",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into company (id, Chinese_name, ",
        "English_name, brief_introduction, ",
        "report_type, repport_url)",
        "values (#{id,jdbcType=INTEGER}, #{chineseName,jdbcType=VARCHAR}, ",
        "#{englishName,jdbcType=VARCHAR}, #{briefIntroduction,jdbcType=VARCHAR}, ",
        "#{reportType,jdbcType=VARCHAR}, #{repportUrl,jdbcType=VARCHAR})"
    })
    int insert(Company record);

    @InsertProvider(type=CompanySqlProvider.class, method="insertSelective")
    int insertSelective(Company record);

    @SelectProvider(type=CompanySqlProvider.class, method="selectByExample")
    @ConstructorArgs({
        @Arg(column="id", javaType=Integer.class, jdbcType=JdbcType.INTEGER, id=true),
        @Arg(column="Chinese_name", javaType=String.class, jdbcType=JdbcType.VARCHAR),
        @Arg(column="English_name", javaType=String.class, jdbcType=JdbcType.VARCHAR),
        @Arg(column="brief_introduction", javaType=String.class, jdbcType=JdbcType.VARCHAR),
        @Arg(column="report_type", javaType=String.class, jdbcType=JdbcType.VARCHAR),
        @Arg(column="repport_url", javaType=String.class, jdbcType=JdbcType.VARCHAR)
    })
    List<Company> selectByExample(CompanyExample example);

    @Select({
        "select",
        "id, Chinese_name, English_name, brief_introduction, report_type, repport_url",
        "from company",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ConstructorArgs({
        @Arg(column="id", javaType=Integer.class, jdbcType=JdbcType.INTEGER, id=true),
        @Arg(column="Chinese_name", javaType=String.class, jdbcType=JdbcType.VARCHAR),
        @Arg(column="English_name", javaType=String.class, jdbcType=JdbcType.VARCHAR),
        @Arg(column="brief_introduction", javaType=String.class, jdbcType=JdbcType.VARCHAR),
        @Arg(column="report_type", javaType=String.class, jdbcType=JdbcType.VARCHAR),
        @Arg(column="repport_url", javaType=String.class, jdbcType=JdbcType.VARCHAR)
    })
    Company selectByPrimaryKey(Integer id);

    @UpdateProvider(type=CompanySqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Company record, @Param("example") CompanyExample example);

    @UpdateProvider(type=CompanySqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Company record, @Param("example") CompanyExample example);

    @UpdateProvider(type=CompanySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Company record);

    @Update({
        "update company",
        "set Chinese_name = #{chineseName,jdbcType=VARCHAR},",
          "English_name = #{englishName,jdbcType=VARCHAR},",
          "brief_introduction = #{briefIntroduction,jdbcType=VARCHAR},",
          "report_type = #{reportType,jdbcType=VARCHAR},",
          "repport_url = #{repportUrl,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Company record);
}